package com.levy.contronller.jvm.classLoader;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Objects;

/**
 * Created by levy on 2019/6/14.
 */
public class MyTest20 {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        MyClassLoader loader1  = new MyClassLoader("loader11");
        MyClassLoader loader2  = new MyClassLoader("loader12");

        loader1.setPath("C:\\Users\\levy\\Desktop\\");
        loader2.setPath("C:\\Users\\levy\\Desktop\\");

        Class<?> clazz1 = loader1.loadClass("com.levy.contronller.jvm.classLoader.MyCat");
        Class<?> clazz2 = loader2.loadClass("com.levy.contronller.jvm.classLoader.MyCat");

        System.out.println(clazz1 == clazz2);

        Object o1 = clazz1.newInstance();
        Object o2 = clazz2.newInstance();

        Method method = clazz1.getMethod("setMyCat", Object.class);
        method.invoke(o1,o2);


    }
}
